package com.zp.testpractice.utils;

import android.app.Dialog;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import com.zp.testpractice.R;

/**
 * @author izp on 2017/11/14.
 */

public class DialogUtils {
    public static void setFullScreenInOnCreateDialog(Dialog dialog){
        // 设置宽度为屏宽、位置靠近屏幕底部
        Window window = dialog.getWindow();
        window.setBackgroundDrawableResource(R.color.transparent);

        setWlp(window);
    }
    public static void setFullScreenInOnCreateView(Dialog dialog){
// 设置宽度为屏宽、靠近屏幕底部。
        Window window = dialog.getWindow();
        window.setBackgroundDrawableResource(R.color.transparent);

//        两个方法就差了这一行？
        window.getDecorView().setPadding(0, 0, 0, 0);
        setWlp(window);
    }

    public static void setWlp(Window window){
        WindowManager.LayoutParams wlp = window.getAttributes();
        wlp.gravity = Gravity.BOTTOM;
        wlp.width = WindowManager.LayoutParams.MATCH_PARENT;
        wlp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(wlp);
    }
}
